package sel.me.spring.beandefinition;

import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.GenericBeanDefinition;

/**
 * @author shenenlu 2021年03月04日 下午21:37:39
 */
public class BeanReferenceLearning {

    public static void main(String[] args) {
        /**
         * 等价于
         * <bean class="beanClassName">
         *     <property name="dataSource" ref="dataSourceBeanName" />
         * </bean>
         */
        GenericBeanDefinition bd = new GenericBeanDefinition();
        bd.setBeanClassName("beanClassName");
        MutablePropertyValues pvs = new MutablePropertyValues();
        pvs.add("ref1", new RuntimeBeanReference("refBeanName1"));
        bd.setPropertyValues(pvs);

        bd.getPropertyValues().add("ref2", new RuntimeBeanReference("refBeanName2"));
        System.out.println(bd);
    }

}
